#include #include #include #include #include #define NX 10 #define NY 10 #define NZ 10 #define nX NX+1 #define nY NY+1 #define nZ NZ+1 #define D 100 #define XM NX*D #define YM NY*D #define ZM NZ*D void ini(FILE *fp); void dr_line(FILE *fp, float p[][3], int n, float *lc); void dr_grid(FILE *fp, float *lc); void dr_scale(FILE *fp, float *lc); void dr_text(FILE *fp, float *tc, float *p); void Viewpoint(FILE *fp); void cal_pc_sub(float th, float pt[][3], float *vt, float *pcs, int *pcts); void cal_pc(float th, float p[][3], float *v, float pc[][3], int *pct); void dr_face(FILE *fp, float p[][3], int n, float *fc, float tr); void mk_index_tri(int indt[][3]); void mk_index_squ(int inds[][5][4]); void mk_triang(FILE *fp, float pc[][3], int *pct, float *fc, float tr); void mk_square(FILE *fp, float pc[][3], int *pct, float *fc, float tr); void mk_index_face(int indf[][4]); void mk_faces(FILE *fp, float pc[][3], int *pct, float *fc, float tr); void count_pc(int *pct, int *num); void search_f(int indf[][4], int self, int next, int *face, int *ptr); void search_p(float pc[][3], int *pct, int indf[][4], int face, int ptr, float *pft, int *next); void mk_equ_face_sub(FILE *fp, float th, float p[][3], float *v, float *fc, float tr); void mk_cube(float x, float y, float z, float p[][3], float v[][nY][nZ], float *vt); void mk_equ_face(FILE *fp, float th, float v[][nY][nZ], float *fc, float tr); void filename(char *file); void light(float *fc, float *lig); void mk_data(float v[][nY][nZ]); void cal_pc20(float th, float p[][3], float *v, float pc[][3], int *pct); void cal_pc21(float th, float p[][3], float *v, float pc[][3], int *pct); void count_pc2(int *pct, int *num); void mk_faces2(FILE *fp, float pcs[][3], int *pcts, float *fc, float tr); void cal_pc3(float th, float p[][3], float *v, float pc[][3], int *pct); void mk_pt_index(int pind[][6]); void mk_equ_face2_sub(FILE *fp, float th, float p[][3], float *v, float *fc, float tr); void mk_equ_face2(FILE *fp, float th, float v[][nY][nZ], float *fc, float tr); void clock_start(clock_t *start); void clock_end(clock_t start); void trans_v(float *v, float *vtr, float p[][3], float ptr[][3]); void mk_cube2(float x, float y, float z, float v[][nY][nZ], float vt[][3][3]); void mk_cube3(float x, float y, float z, float dx, float dy, float dz, float p[][3], float v[][3][3], float *vt); void mk_equ_face001(FILE *fp, float th, float v[][nY][nZ], float *fc, float tr); void rm_cube(float th, float *vt, int *rm); void mk_equ_face0021(FILE *fp, float x, float y, float z, float th, float v[][nY][nZ], float *fc, float tr); void mk_equ_face002(FILE *fp, float th, float v[][nY][nZ], float *fc, float tr); void ini(FILE *fp) { fprintf(fp, "#VRML V2.0 utf8\n"); } void dr_line(FILE *fp, float p[][3], int n, float *lc) { int i; fprintf(fp, "\nShape{"); fprintf(fp, "appearance Appearance{"); fprintf(fp, "material Material{"); fprintf(fp, "diffuseColor 0 0 0"); fprintf(fp, "}"); fprintf(fp, "}"); fprintf(fp, "geometry IndexedLineSet{"); fprintf(fp, "coord Coordinate{"); fprintf(fp, "point["); for(i=0; i < n ;i++) fprintf(fp, "%.0f %.0f %.0f ",p[i][0], p[i][1], p[i][2]); fprintf(fp, "]"); fprintf(fp, "}"); fprintf(fp, "coordIndex["); for(i=0; i < n ;i++) fprintf(fp, "%d ", i); fprintf(fp, "]"); fprintf(fp, "color Color{"); fprintf(fp, "color["); for(i=0; i < n; i++) fprintf(fp, "%f %f %f ",lc[0],lc[1],lc[2]); fprintf(fp, "]"); fprintf(fp, "}"); fprintf(fp, "colorIndex["); for(i=0; i < n ;i++) fprintf(fp, "%d ", i); fprintf(fp, "]"); fprintf(fp, "}"); fprintf(fp, "}"); } void dr_grid(FILE *fp, float *lc) { int j,k; float gp[2][3]; for(j=0; j=th)&&(vt[1]>=th) )||( (vt[0]=th ){ uc++; }else if( vt[i]